Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to assert that migrations are ordered as we declared them #467

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

gianarb
Copy link
Contributor

@gianarb gianarb commented Mar 26, 2021

This tests is coming from this PR
#466

We didn't fully understood how the migration library sorts migration
before having to troubleshoot that PR. Even if we declare them in order
as part of the GetMigrations function the library still applies quick
sort on the migration ID to stay concurrency safe

https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.goL216

In order to improve the visbility and to akwnoldge that the way we
append migrations to GetMigrations is the same we get after the sorting
we wrote this tests.

I will start a conversation with the lib maintainer to figure out how we can improve our current workflow.

@gianarb gianarb requested a review from gauravgahlot March 26, 2021 09:56
@gianarb gianarb force-pushed the chore/add-test-to-check-migration-order branch from 4416404 to 2bb0a9f Compare March 26, 2021 09:58
@gianarb gianarb added the ready-to-merge Signal to Mergify to merge the PR. label Mar 26, 2021
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #467 (35ddabc) into master (0f2a86f) will not change coverage.
The diff coverage is n/a.

❗ Current head 35ddabc differs from pull request most recent head 8face1a. Consider uploading reports for the commit 8face1a to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #467   +/-   ##
=======================================
  Coverage   35.82%   35.82%           
=======================================
  Files          47       47           
  Lines        2892     2892           
=======================================
  Hits         1036     1036           
  Misses       1763     1763           
  Partials       93       93           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f2a86f...8face1a. Read the comment docs.

Copy link
Contributor

@gauravgahlot gauravgahlot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than the small corrections.

//
// https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.go#L216
//
// In order to improve the visbility and to akwnoldge that the way we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// In order to improve the visbility and to akwnoldge that the way we
// In order to improve the visibility and to acknowledge that the way we

// A possible solution is to write our own MigrationSet who won't do the
// ordering. In the meantime I (gianarb) will start a conversation with library
// maintainer to figure out how we can improve this.
func TestMigrationAreOrderendInTheWayWeDeclaredThem(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestMigrationAreOrderendInTheWayWeDeclaredThem(t *testing.T) {
func TestMigrationsAreOrderendInTheWayWeDeclaredThem(t *testing.T) {

t.Fatal(err)
}
if len(declaredMigration) != len(orderedMigration) {
t.Error("migrations have not the same number of elements. This should never happen.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Error("migrations have not the same number of elements. This should never happen.")
t.Error("Migrations do not have the same number of elements. This should never happen.")

@gianarb gianarb force-pushed the chore/add-test-to-check-migration-order branch from 2bb0a9f to 8ec9ce1 Compare March 26, 2021 10:18
This tests is coming from this PR
#466

We didn't fully understood how the migration library sorts migration
before having to troubleshoot that PR. Even if we declare them in order
as part of the GetMigrations function the library still applies quick
sort on the migration ID to stay concurrency safe

https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.goL216

In order to improve the visbility and to akwnoldge that the way we
append migrations to GetMigrations is the same we get after the sorting
we wrote this tests.

Signed-off-by: Gianluca Arbezzano <[email protected]>
@gianarb gianarb force-pushed the chore/add-test-to-check-migration-order branch from 8ec9ce1 to 8face1a Compare March 26, 2021 10:19
@mergify mergify bot merged commit a49e7e6 into master Mar 26, 2021
@mergify mergify bot deleted the chore/add-test-to-check-migration-order branch March 26, 2021 10:25
@gianarb gianarb mentioned this pull request Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants